﻿namespace Pub.Class
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Runtime.CompilerServices;

    public static class ICollectionExtensions
    {
        public static bool AddUnique<T>(this ICollection<T> collection, T value)
        {
            if (!collection.Contains(value))
            {
                collection.Add(value);
                return true;
            }
            return false;
        }

        public static int AddUnique<T>(this ICollection<T> collection, IEnumerable<T> values)
        {
            int num = 0;
            foreach (T local in values)
            {
                if (collection.AddUnique<T>(local))
                {
                    num++;
                }
            }
            return num;
        }

        public static bool IsNullEmpty(this ICollection self)
        {
            if (!self.IsNull())
            {
                return (self.Count == 0);
            }
            return true;
        }
    }
}

